#ifndef _NE_MIDI_OUT_DEVICE_MACOSX_H_
#define _NE_MIDI_OUT_DEVICE_MACOSX_H_

#include <audio/MIDI/MIDIOutDevice.h>

#if NE_PLATFORM == NE_PLATFORM_MACOSX

#include <CoreMIDI/CoreMIDI.h>

namespace ne
{
    class NEAPI MIDIOutDeviceMacOSX : public MIDIOutDevice
    {
        public:
            MIDIOutDeviceMacOSX(const uint32_t id, const std::string &name);

            virtual bool open();

            virtual bool reset();

            virtual bool close();

            virtual bool sendEvent(const byte event, const byte parameter1, const byte parameter2);

            virtual bool sendSysExEvent(const byte *buffer, const uint32_t length);

            virtual ~MIDIOutDeviceMacOSX();

        protected:
            virtual bool _create();

            virtual bool _destroy();

        public:
            static void NotifyCallback(const MIDINotification *message, void *refCon);

            static void ReadCallback(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon);
            static void CompletionCallback(MIDISysexSendRequest *request);

        private:
            MIDIClientRef mClient;
            MIDIEndpointRef mDestination;
            MIDIPortRef mOutPort;
    };
}

#endif

#endif
